#include "peopleitem.h"
#include "ui_peopleitem.h"
#include<QUuid>
#include<QDateTime>
PeopleItem::PeopleItem(QWidget *parent,int row,QString name,QPixmap pm)
    : QWidget(parent)
    , ui(new Ui::PeopleItem)
{
    ui->setupUi(this);
    init(name,pm);
    peoplerow=row;
}

PeopleItem::~PeopleItem()
{
    delete ui;
}

void PeopleItem::DealLastMesRenew(const QString &mes)
{
    last_mes=mes;
    ui->peopleLastMes->setText(last_mes);
}

void PeopleItem::init(QString name, QPixmap pm)
{
    people_name=name;
    people_icon=pm;
    PeopleId=QUuid::createUuid().toString();
    ui->PeopleImage->setPixmap(people_icon);
    ui->PeopleImage->setScaledContents(true);
    ui->peopleName->setText(people_name);
    repaint();
}

void PeopleItem::AddOneMes(QString mes, QPixmap pm, QString time,bool own)
{
    if(pm.isNull())
        qDebug()<<"widget39 pm nullptr";
    PeopleMes* Pm=new PeopleMes(this,mes,time,pm,own);
    allpeoplemes.push_back(Pm);
}
